part of '../repository.dart';

class _LexicalItemDtoFactory {
  const _LexicalItemDtoFactory._internal();

  static const _instance = _LexicalItemDtoFactory._internal();

  factory _LexicalItemDtoFactory() {
    return _instance;
  }

  _LexicalItemDto fromJson(Map<String, dynamic> json) {
    final type = json[_kLexicalItemTypeKey] as String;

    switch (type) {
      case _kLexicalItemAdjectiveType:
        return _AdjectiveDto.fromJson(json);
      case _kLexicalItemAdverbType:
        return _AdverbDto.fromJson(json);
      case _kLexicalItemConjunctionType:
        return _ConjunctionDto.fromJson(json);
      case _kLexicalItemNounType:
        return _NounDto.fromJson(json);
      case _kLexicalItemNumeralType:
        return _NumeralDto.fromJson(json);
      case _kLexicalItemPrepositionType:
        return _PrepositionDto.fromJson(json);
      case _kLexicalItemPronounType:
        return _PronounDto.fromJson(json);
      case _kLexicalItemVerbType:
        return _VerbDto.fromJson(json);
      case _kLexicalItemPhrasalVerbType:
        return _PhrasalVerbDto.fromJson(json);
      default:
        throw UnimplementedError();
    }
  }
}
